package fiuba.td.fabrica.controller;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Observable;

import org.apache.log4j.Logger;

import fiuba.td.fabrica.constants.GlobalConstants;
import fiuba.td.fabrica.model.entities.Terreno;
import fiuba.td.fabrica.model.exceptions.SinDineroException;
import fiuba.td.fabrica.model.partida.Partida;
import fiuba.td.fabrica.view.utils.AlertUtils;

public class ControllerAlquilarTerreno extends Observable implements MouseListener {
	static Logger logger = Logger.getLogger(ControllerAlquilarTerreno.class);
	
	Terreno terrenoSeleccionado;
	
	public ControllerAlquilarTerreno(){
		super();		
	}
	
	public void mouseClicked(MouseEvent arg0) {
		this.terrenoSeleccionado = ControllerSelection.getInstance().getTerrenoSeleccionado();

		try {
			Partida.getInstance().alquilarTerreno(this.terrenoSeleccionado, "Fabrica Cool");
			setChanged();
			notifyObservers(GlobalConstants.BOTON_TERRENOS_ALQUILAR);
		} catch (SinDineroException e) {
			AlertUtils.show("No tiene dinero suficiente para alquilar el terreno.");
		}
	}

	
	public void mouseEntered(MouseEvent arg0) {
	}

	
	public void mouseExited(MouseEvent arg0) {
	}

	
	public void mousePressed(MouseEvent arg0) {
	}

	
	public void mouseReleased(MouseEvent arg0) {
	}

}
